const int inf = 1e9;
void solve()
{
  int n, m, q;
  cin >> n >> m >> q;

  vvi g(n + 1);
  vector<vector<int>> edges;
  
  rep(i, 1, m) {
    int u, v, w;
    cin >> u >> v >> w;
    g[u].pb(v);
    g[v].pb(u);
    edges.pb({w, u, v});
  }
  
  vi val(m + 1);
  vvvi dst(n + 1, vvi(n + 1, vi(n + 1, inf)));
  auto bfs = [&](int v) {
    vi dis(n + 1, inf);
    queue<int> q;
    q.push(v);
    dis[v] = 0;

    while (!q.empty()) {
      int u = q.front();
      q.pop();

      for (auto &j : g[u]) {
        if (dis[j] > dis[u] + 1) {
          dis[j] = dis[u] + 1;
          q.push(j);
        }
      }
    }

    rep(i, 1, n) {
      dst[0][v][i] = dis[i];
    }
  };

  rep(i, 1, n) {
    bfs(i);
  }

  sort(all(edges));
  int cur = 0;
  val[0] = 0;
  rep(i, 0, m - 1) {
    int w = edges[i][0], u = edges[i][1], v = edges[i][2];
    if (dst[cur][u][v] == 0) {
      val[i + 1] = cur;
      continue;
    }
    val[i + 1] = ++cur;
    dst[cur] = dst[cur - 1];
    dst[cur][u][v] = dst[cur][v][u] = 0;
    rep(i, 1, n) {
      rep(j, 1, n) {
        dst[cur][i][j] = min(dst[cur][i][j], dst[cur][i][u] + dst[cur][v][j]);
        dst[cur][j][i] = min(dst[cur][j][i], dst[cur][j][u] + dst[cur][v][i]);
      }
    }
    rep(i, 1, n) {
      rep(j, 1, n) {
        dst[cur][i][j] = min(dst[cur][i][j], dst[cur][j][i]);
      }
    }
  }

  while (q--) {
    int a, b, k;
    cin >> a >> b >> k;

    int ans = 0, l = 0, r = m;
    while (l <= r) {
      int mid = (l + r) >> 1;
      if (dst[val[mid]][a][b] >= k) {
        ans = mid;
        l = mid + 1;
      } else {
        r = mid - 1;
      }
    }

    cout << edges[ans][0] << ' ';
  }
  cout << '\n';
}